/* 
 * File:   server.h
 * Author: Faraj
 *
 * Created on May 11, 2013, 2:41 PM
 */

#ifndef WEB_SERVER_H
#define	WEB_SERVER_H

#include <vector>
#include <map>
#include "../lib/resource.h"
#include "../lib/server.h"
#include "../lib/common/str.h"
#include "../lib/common/os.h"
#include "../lib/common/log.h"
#include "../lib/config.h"
#include "../lib/url.h"

namespace web {

    class web_server : public lib::server {
    public:
        web_server();
        virtual ~web_server();
        void start();
        void conf(lib::config *conf, string root_key);
        void conf_root(lib::config *conf, string root_key);
        void add_root(string name, string path);
        void set_home(string home_files);
        //const
        static const string DEFAULT_WEBROOT;
    private:
        map<string, string> _roots;
        vector<string> _home_files;
        static vector<web_server> _servers;
        static int _response(void *cls, struct MHD_Connection *connection,
                const char *url, const char *method,
                const char *version, const char *upload_data,
                size_t *upload_data_size, void **con_cls);
    };
};
#endif	/* WEB_SERVER_H */

